<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'questionnaire.label', default: 'Questionnaire')}"/>
    <title>问卷模板：${this.questionnaire?.name}</title>
</head>

<body class="fixed-navbar fixed-sidebar">
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>贷款管理系统</li>
                    <li><g:link controller="questionnaire" action="index">问卷模板</g:link></li>
                    <li class="active">
                        <span>${this.questionnaire?.name}</span>
                    </li>
                </ol>
            </div>
            <h2 class="font-light m-b-xs" style="text-transform:none;">
                问卷模板：${this.questionnaire?.name}
            </h2>
        </div>
    </div>
</div>

<div class="content animate-panel">

    <div class="row">
        <div class="hpanel hblue">
            <div class="panel-heading">
                <div class="panel-tools">
                  <g:link class="btn btn-info btn-xs" action="preview" id="${this?.questionnaire?.id}"><i class="fa fa-edit"></i>预览</g:link>
                    <g:link class="btn btn-info btn-xs" action="edit" resource="${this.questionnaire}"
                            id="${this?.questionnaire?.id}"><i class="fa fa-edit"></i>编辑</g:link>
                </div>
                问卷模板
            </div>

            <div class="panel-body">
                <div class="text-muted font-bold m-b-xs ol-md-6">
                    <div class="col-md-12"><h4><a href=>${this.questionnaire.name}</a></h4></div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="hpanel hyellow">
            <div class="panel-heading">
                <div class="panel-tools">
                  <sec:ifNotGranted roles="ROLE_COO">
                    <g:link class="btn btn-xs btn-info" controller="question" action="create"
                             params="[questionnaire: this.questionnaire.id]"><i class="fa fa-plus"></i>新增</g:link>
                          </sec:ifNotGranted>
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                问题
            </div>

            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <g:sortableColumn property="name" title="名称"/>
                            <g:sortableColumn property="description" title="类型"/>
                            <g:sortableColumn property="dataType" title="问题类型"/>
                            <g:sortableColumn property="displayOrder" title="展示次序"/>
                            <g:sortableColumn property="displayOrder" title="删除"/>

                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${this.questionnaire?.questions}">
                            <div class="col-md-4">
                                <tr>
                                    <td><g:link action="show" controller="question" id="${it?.id}"
                                                class="firstTd">${it?.name}</g:link></td>
                                    <td>${it?.type}</td>
                                    <td>${it?.questionType}</td>
                                    <td>${it?.displayOrder}</td>
                                    <td>
                                    <g:form controller="question" action="delete" id="${it.id}" method="DELETE">
                                        <button class="deleteBtn btn btn-danger btn-xs btn-outline" type="button"><i class="fa fa-trash-o"></i> 删除</button>
                                    </g:form>
                                  </td>

                                </tr>
                            </div>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="hpanel hyellow">
            <div class="panel-heading">
                <div class="panel-tools">

                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                提交记录
            </div>

            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <g:sortableColumn property="name" title="客户姓名"/>
                            <g:sortableColumn property="name" title="提交时间"/>


                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${this.questionnaireInstances}">
                            <div class="col-md-4">
                                <tr>
                                    <td><g:link action="show" controller="questionnaireInstance" id="${it?.id}"
                                                class="firstTd">${it?.opportunity?.contact?.fullName}</g:link></td>
                                   <td>${it?.createdDate}</td>


                                </tr>
                            </div>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
